// 导入 http 模块
const http = require("http");
const { URL } = require("url");

// 创建服务对象
const server = http.createServer((request, response) => {
  // 实例化 uri 的对象
  let url = new URL(request.url, "http://127.0.0.1");
  // 输出路径
  console.log(url.pathname);
  // 输出 keyword 查询字符串
  console.log(url.searchParams.get("keyword"));
  console.log(url.searchParams.get("password"));
  response.end("uri");
});

// 监听端口，启动服务
server.listen(9000, () => {
  console.log("服务已经启动……");
});
